<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.List" %>
<%@ page import="org.example.login2.Student" %>
<!DOCTYPE html>
<html>
<head>
    <title>学生成绩列表</title>
</head>
<body>
<h1>学生成绩列表</h1>
<link rel="stylesheet" type="text/css" href="styles.css">
<form action="saveStudent" method="post">
    <table border="1">
        <tr>
            <th>学号</th>
            <th>姓名</th>
            <th>专业</th>
            <th>平时成绩</th>
            <th>期末成绩</th>
            <th>总成绩</th>
            <th>操作</th>
        </tr>
        <%
            List<Student> studentList = (List<Student>) request.getAttribute("studentList");
            if (studentList != null) {
                for (Student student : studentList) {
        %>
        <tr>
            <td><%= student.getId() %></td>
            <td><%= student.getName() %></td>
            <td><%= student.getMajor() %></td>
            <td>
                <input type="text" name="regularScore_<%= student.getId() %>" value="<%= student.getRegularScore() %>">
            </td>
            <td>
                <input type="text" name="finalScore_<%= student.getId() %>" value="<%= student.getFinalScore() %>">
            </td>
            <td><%= student.getTotalScore() %></td>
            <td><a href="deleteStudent?id=<%= student.getId() %>">删除</a></td>
        </tr>
        <%
            }
        } else {
        %>
        <tr>
            <td colspan="7">没有学生数据</td>
        </tr>
        <%
            }
        %>
    </table>
    <input type="submit" value="提交成绩">
</form>
<br>
<div class="center">
    <a class="button" href="newStudent.jsp">新增学生</a>
</div>
</body>
</html>
